//
//  Item.swift
//  SwiftUILean
//
//  Created by wyknmjj on 2024/5/14.
//

import SwiftUI


struct PinterestItem: Identifiable,Hashable{
    private(set)var id: UUID = .init()
    var title: String
    var image: UIImage?
}

func getSamplePinterestItems()async ->  [PinterestItem]{
    return await withTaskGroup(of: PinterestItem.self) { group in
        Array(1...30).forEach { i in
            group.addTask {
               let image = try! await fetchImage("https://loremflickr.com/320/240/paris,girl/all?v=\(i)")
               return PinterestItem(title: "title\(i)",image: image)
            }
        }
            
        var data: [PinterestItem] = []
        for await i in group { data.append(i) }
        return data
    }
}
